/**
 * Created with CLion.
 * Description: 
 * User: loong
 * Date: 2025/4/22
 * Time: 22:44
 */

#ifndef SCENE_H
#define SCENE_H
#include "Object.h"

#include <glm/glm.hpp>
#include <vector>

class ObjectWorld;
class ObjectScreen;
class Scene : public Object
{
public:
    Scene()           = default;
    ~Scene() override = default;

    void Init() override;
    void Update(float _dt) override;
    void Render() override;
    void Clean() override;
    void HandleEvent(SDL_Event & _event) override;

    void AddChild(Object* child) override;
    void RemoveChild(Object* child) override;

    glm::vec2 GetCameraPosition() const { return camera_position_; }
    void      SetCameraPosition(const glm::vec2 & _camera_position);

    glm::vec2 GetWorldSize() const { return world_size_; }
    void      SetWorldSize(const glm::vec2 & _world_size) { world_size_ = _world_size; }

    glm::vec2 WorldToScreen(const glm::vec2 & _world_position) const { return _world_position - camera_position_; }
    glm::vec2                     ScreenToWorld(const glm::vec2 & _screen_position) const { return _screen_position + camera_position_; }

    std::vector<ObjectWorld *> &  ChildrenWorld() { return children_world_; }
    std::vector<ObjectScreen *> & ChildrenScreen() { return children_screen_; }

protected:
    glm::vec2 camera_position_ {0};
    glm::vec2 world_size_ {0};

    std::vector<ObjectWorld *>  children_world_;
    std::vector<ObjectScreen *> children_screen_;
};

#endif//SCENE_H
